1. Field of Invention
The invention relates to a network device and an address learning method thereof, and, in particular, to a network device having a programmable logic device and an address learning method thereof.
2. Related Art
In the LAN (Local Area Network), a network device, such as a switch, is used to enable the data transmission between various terminal devices. The switch works on a second layer (i.e., data link layer) in a network OSI model, so the switch can recognize a MAC (Media Access Control) address of a terminal device connected thereto. Thus, if the switch knows the MAC address of each terminal device in advance, the switch only has to transfer the data packet to a specific terminal device according to the MAC address without broadcasting the data packet. Consequently, a large portion of the network bandwidth may be saved, and the transmission rate can be enhanced. The broadcasting method is to transfer the data packet out through all connection ports of the switch.
As shown in FIG. 1, a LAN (e.g., Ethernet) 1 is composed of a switch 11 and a plurality of terminal devices 12-15. The switch 11 has a plurality of connection ports 111-114. The terminal devices 12-15 are connected to the corresponding connection ports 111-114, respectively. When the terminal device 12 wants to transfer a data packet 121 to the terminal device 13, a target address has to be specified in the data packet 121 according to the Ethernet protocol. That is, the MAC address of the terminal device 13 is a 48-bit binary code, and the data packet 121 also includes a source address (i.e., the MAC address of the terminal device 12).
In addition, the switch 11 further has an address table, which is a look-up table for storing the MAC address of the terminal device and the connection port connected to the terminal device. The address table is recorded in a memory of the switch 11. When the terminal device 12 transfers the data packet 121 to the switch 11 through the connection port 111, the switch 11 performs two operations on the address table thereof. First, the switch 11 checks whether the address table has the source address of the data packet 121 through the program software. If not, the source address and the corresponding connection port 111 are written into the address table. Consequently, the switch 11 knows that the terminal device 12 is connected to the connection port 111. This is the so-called “address learning function”.
Then, the switch 11 checks whether the address table has the target address (the MAC address of the terminal device 13) of the data packet 121. If yes, the switch 11 transfers the data packet 121 to the terminal device 13 through the connection port 112 connected to the terminal device 13 according to the address table. If the address table has no MAC address of the terminal device 13, the data packet 121 is transferred to other connection ports 112-114 of the switch 11. At this time, the data packet 121 is transferred by way of broadcasting. It is to be noted that the network transmission speed is decreased because the bandwidth is occupied by a lot of data packets when there are too many data packets transferred by way of broadcasting.
In addition, the switch 11 can support the virtual LAN (VLAN) technology. Simply speaking, the VLAN includes a plurality of sub-LANs divided from the whole LAN. For example, the terminal devices 12, 13 of FIG. 1 may be set as a first VLAN VLAN1, and the terminal devices 14, 15 may be set as a second VLAN VLAN2. Thus, when the data packet 121 becomes a broadcasting data packet, the switch 11 broadcasts the data packet 121 to the VLAN1 (only the terminal device 13 in this example), and the terminal device 13 is just the terminal device for receiving the packet. The broadcasting may be reduced according to the VLAN technology.
The switch 11 performs the address learning function by a software program. This is because the switch is only applied to the small range of the LAN as it is initially developed. That is, the number of terminal devices connected to the switch is smaller, and the address learning rate for the switch 11 is about 300 to 400 addresses per second. So, the requirement can be satisfied and the hardware cost can be saved when the software program is used to perform the address learning. However, the network is gradually popularized and is getting faster and faster, so the range of the LAN is getting larger and larger. For example, the address learning rate for the switch 11 in the Metro Ethernet will be higher than 128 k addresses per second, which depends on the scale of the Metro Ethernet. Consequently, when some topology changes occur, the data packet may be lost because the address learning speed of the switch 11 is not high enough. In addition, the switch 11 also has to broadcast a lot of packets, such that the network storm occurs and the transmission speed of the LAN is greatly reduced.
Thus, it is an important subject of the invention to provide a network device and an address learning method thereof, such that the address learning speed of the network device can be increased in the large LAN and the transmission speed and efficiency of the LAN may be increased.